<template>
	<!-- 我的钱包 -->
	<view>
		<view class="head-box yh-fcF">
			
			<view class="yh-pd30 yh-bgf yh-br12 yh-fcF_8 yh-mt40 yh-bs-tc">
				
				<view class="">
					<view style="background: #fff;padding: 10px;margin-top: 10px;" class="level_align flex_between yh-bdbm yh-bdbm-last" v-for="(item,index) in list" :key="index">
					
						<view class="yh-fc333 yh-mt10">
							<view class="yh-lh64 yh-fz34">
								{{item.memo}} {{item.score}}个
							</view>
							<view class="yh-lh54">
								{{item.createtime}}
							</view>
						</view>
					
					</view>
					<noData :noDataShow="noDataShow" hintText="暂无明细"></noData>
					<!--list-->
					
				</view>
			</view>
			<!--加载loadding-->
			<tui-loadmore v-if="loadding" :index="3" type="red"></tui-loadmore>
			<tui-nomore v-if="!pullUpOn" backgroundColor="#f7f7f7"></tui-nomore>
			<!--加载loadding-->
		</view>
	</view>
</template>

<script>
	import noData from '@/components/noData.vue'
	export default {
		components: {
			noData
		},
		data() {
			return {
				pageIndex: 1, // 当前页
				has_more: false, // 是否有更多
				loadding: false,
				pullUpOn: true,
				list: [],
				money:'',
				type:0,
				
				page: 1,
				total: 0,
				list: [],
			}
		},
		onLoad: function(options) {
			this.type = options.type;
			this.getList();
			
		},
		onReachBottom: function() {
			if (this.list.length < this.total) {
				this.page++;
				this.getList();
			}
		},
		computed: {
			noDataShow() {
				return !this.list.length
			}
		},
		methods: {
			getInfo(){
				uni.showLoading({
					title: '加载中...'
				})
				this.$http.get(this.$api.userWallet, {
					page: this.pageIndex,
					size: 10
				}).then(res => {
					uni.hideLoading()
					this.loadding = false;
					if (res.code === 1) {
						this.money = res.data.money
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			getList() { // 获取明细列表
				
				uni.showLoading({ title: '正在加载', mask: true });
				var _this = this;
				_this.$api.request('/api/user/topups', {page:this.page,	type:this.type}, uni.getStorageSync('token'), function(res) {
					uni.hideLoading();
					if (res.code == 1) {
						_this.total = res.data.total;
						_this.score = res.data.score
						if (_this.page == 1) {
							_this.list = res.data.data;
						} else {
							_this.list = _this.list.concat(res.data.data);
						}
					}
					uni.hideLoading();
				});
				
			}
			
		}
	}
</script>

<style lang="less">
	.head-box {
		position: relative;
		z-index: 99;
		width: 100%;
		padding: 0 30rpx 60rpx;
		box-sizing: border-box;

		background-repeat: no-repeat;
		background-position: top center;
		background-size: 100%;
	}
</style>
